﻿namespace Sunny.Service
{
    public class CodeMessage
    {
        public int Code { get;  }
        public string Message { get; private set;}
        
        public CodeMessage SetMessage(string message)
        {
            this.Message = message;
            return this;
        }

        public CodeMessage(int code, string msg)
        {
            this.Code = code;
            this.Message = msg;
        }

        #region 100以内,表示非错误提示,依据此code前端进行一些业务操作
        /// <summary>
        /// 用户未登录-接口正常，但是用户未登录，前端根据code提示用户去登录页面或弹窗登录
        /// </summary>
        public static  readonly CodeMessage NotLogin = new CodeMessage(10,"用户未登录");

        #endregion
        
        #region 用户相关 10xx
        /// <summary>
        /// 验证码已失效
        /// </summary>
        public static readonly CodeMessage CaptchaExpire = new CodeMessage(1001, "验证码已失效");
        /// <summary>
        /// 验证码已错误
        /// </summary>
        public static readonly CodeMessage CaptchaInvalid = new CodeMessage(1002, "验证码错误");
        /// <summary>
        /// 用户名或密码错误
        /// </summary>
        public static readonly CodeMessage UserUsernameOrPasswordError = new CodeMessage(1010, "用户名或密码错误");
        /// <summary>
        /// 用户不存在
        /// </summary>
        public static readonly CodeMessage UserNotExists = new CodeMessage(1011, "用户不存在");
        /// <summary>
        /// 原密码错误
        /// </summary>
        public static readonly CodeMessage UserOldPasswordInvalid = new CodeMessage(1012, "原密码错误");
        /// <summary>
        /// token无效
        /// </summary>
        public static readonly CodeMessage TokenInvalid = new CodeMessage(401, "token无效");
        /// <summary>
        /// 没有操作权限
        /// </summary>
        public static readonly CodeMessage HasNoPermission = new CodeMessage(403, "没有操作权限");
        /// <summary>
        /// 不允许操作超级管理员用户
        /// </summary>
        public static readonly CodeMessage AdminNotAllowedEdit = new CodeMessage(1020, "不允许操作超级管理员用户");
        /// <summary>
        /// 手机号已存在
        /// </summary>
        public static readonly CodeMessage UserPhoneExists = new CodeMessage(1021, "手机号已存在");
        /// <summary>
        /// 用户名已存在
        /// </summary>
        public static readonly CodeMessage UserNameExists = new CodeMessage(1022, "用户名已存在");
        /// <summary>
        /// 邮箱已存在
        /// </summary>
        public static readonly CodeMessage UserEmailExists = new CodeMessage(1023, "邮箱已存在");
        /// <summary>
        /// 角色不存在
        /// </summary>
        public static readonly CodeMessage RoleNotExists = new CodeMessage(1030, "角色不存在");
        
        /// <summary>
        /// 存在子菜单,不允许删除
        /// </summary>
        public static readonly CodeMessage MenuHasChild = new CodeMessage(1040, "存在子菜单,不允许删除");
        /// <summary>
        /// 存在子菜单,不允许删除
        /// </summary>
        public static readonly CodeMessage MenuHasRole = new CodeMessage(1041, "菜单已分配,不允许删除");
        
        /// <summary>
        /// 存在子部门,不允许删除
        /// </summary>
        public static readonly CodeMessage DeptHasChild = new CodeMessage(1050, "存在子部门,不允许删除");
        /// <summary>
        /// 部门存在用户,不允许删除
        /// </summary>
        public static readonly CodeMessage DeptHasUser = new CodeMessage(1051, "部门存在用户,不允许删除");
        
        /// <summary>
        /// 岗位编码已存在
        /// </summary>
        public static readonly CodeMessage PostCodeExists = new CodeMessage(1051, "岗位编码已存在");
        /// <summary>
        /// 岗位名称已存在
        /// </summary>
        public static readonly CodeMessage PostNameExists = new CodeMessage(1051, "岗位名称已存在");
        /// <summary>
        /// 已分配用户,不能删除
        /// </summary>
        public static readonly CodeMessage PostHasUser = new CodeMessage(1052, "已分配用户,不能删除");
        
        /// <summary>
        /// 参数键已存在
        /// </summary>
        public static readonly CodeMessage ConfigKeyExists = new CodeMessage(1060, "参数键已存在");
        #endregion

        #region 字典相关 200xx
        /// <summary>
        /// 无法删除
        /// </summary>
        public static readonly CodeMessage CanNotDelete = new CodeMessage(20001, "无法删除");
        
        /// <summary>
        /// 车辆不存在
        /// </summary>
        public static readonly CodeMessage VehicleNotExists = new CodeMessage(20002, "车辆不存在");
        #endregion
        
        

        #region 其他....
        /// <summary>
        /// 未知错误
        /// </summary>
        public static readonly CodeMessage UnknownError = new CodeMessage(50001, "服务器出现异常，请稍后重试");
        
        #endregion

        #region 第三方接口错误

        /// <summary>
        /// 吉利接口key错误
        /// </summary>
        public static readonly CodeMessage GeelyKeyError = new CodeMessage(60001, "请求key错误");

        #endregion
    }
}